package main

import (
	"fmt"
	kithttp "github.com/go-kit/kit/transport/http"
	"go-kit-demo/endpoint"
	"go-kit-demo/service"
	"go-kit-demo/transport"
	"net/http"
)

// 服务发布
func main() {

	// 1. 生成核心service
	userService := service.UserService{}

	// 2. 初始化endpoint，注入service
	endpoint := endpoint.GenerateUserEndpoint(&userService)

	fmt.Println("访问: http://localhost:8080?id=0 服务") // 可以删去仅仅提示
	// 3. 发布服务
	serverHandle := kithttp.NewServer(endpoint, transport.DecodeUserRequest, transport.EncodeUserResponse)
	http.ListenAndServe(":8080", serverHandle)
}
